package com.aaa.springboot_rbac.controller;

import com.aaa.springboot_rbac.entity.Emp;
import com.aaa.springboot_rbac.service.DeptService;
import com.aaa.springboot_rbac.service.EmpService;
import com.aaa.springboot_rbac.util.Page;
import com.aaa.springboot_rbac.util.Result;
import com.aaa.springboot_rbac.util.ResultUtil;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @FileName: EmpController
 * @Description:
 * @Author: 张钰哲
 * @CreateTime: 2025/8/27 16:10
 * @Version: 1.0.0
 */
@RestController
@RequestMapping("emp")
public class EmpController {
    @Resource
    private EmpService empService;

    @PostMapping("queryByPage")
    public Result queryByPage(@RequestBody Page<Emp> page) {
        PageInfo pageInfo = empService.queryByPage(page);
        return ResultUtil.success(pageInfo);
    }

    @GetMapping("queryByEmpNo")
    public Result queryByEmpNo(Integer empNo) {
        return ResultUtil.success(empService.queryByEmpNo(empNo));
    }

    @PostMapping("add")
    public Result add(@RequestBody Emp emp) {
        return ResultUtil.success(empService.add(emp));
    }

    @PostMapping("update")
    public Result update(@RequestBody Emp emp) {
        return ResultUtil.success(empService.update(emp));
    }

    @DeleteMapping("deleteByNo")
    public Result deleteByNo(Integer empNo) {
        return ResultUtil.success(empService.deleteByNo(empNo));
    }
}
